package server;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.scene.Group;
import javafx.event.EventHandler;
import javafx.scene.input.MouseEvent;
import server.control.*;

public class Main extends Application{
	public static void main(String[] args){
		launch(Main.class, "");
	}

	double x, y;
	Stage stage;
	ServerController sc;

	@Override
	public void start(Stage primaryStage){
		try{
			AnchorPane ap = (AnchorPane) FXMLLoader.load(Main.class.getResource("monitor.fxml"));
			Group group = new Group();
			stage = new Stage(StageStyle.UNDECORATED);
			group.setOnMousePressed(new EventHandler<MouseEvent>(){
				public void handle(MouseEvent me){
					x = me.getScreenX() - stage.getX();
					y = me.getScreenY() - stage.getY();
				}
			});
			group.setOnMouseDragged(new EventHandler<MouseEvent>(){
				public void handle(MouseEvent me){
					stage.setX(me.getScreenX() - x);
					stage.setY(me.getScreenY() - y);
				}
			});
			group.getChildren().add(ap);
			Scene scene = new Scene(group);
			stage.setScene(scene);
			stage.show();
			sc = new ServerController();
		}catch(Exception e){
			//e.printStackTrace();
		}
	}
}